﻿@model Peninsula.DataAccess.POCO.Admin

@{
    bool isEdit = ViewBag.IsEdit;
    string title = isEdit ? "编辑" : "创建";
}

@section Styles{
    @Styles.Render(BundleConfig.BootstrapUploadCssBundle)
    <style type="text/css">
    </style>
}
@section Scripts{
    @Scripts.Render(BundleConfig.BootstrapUploadJsBundle)
    <script type="text/javascript">
        $(function () {
        });
    </script>
}


<!-- BEGIN FORM PORTLET -->
<div class="portlet">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-reorder"></i>@(title)店面管理员
        </div>
    </div>
    <div class="portlet-body form">

        @using (Html.BeginForm("CreateOrEditStoreManger", "StoreManger", FormMethod.Post,
                        new { @class = "form-horizontal js-form js-ajax-form", enctype = "multipart/form-data", id = "fileupload" }))
        {
            @Html.AntiForgeryToken()
            @Html.HiddenFor(m => m.Id)
            @Html.Hidden("isEdit", isEdit)
            @Html.HiddenFor(m=>m.StoreManger.QQEmailCode)
            <div class="form-body">
                <div class="form-group">
                    <label class="control-label col-md-3">选择头像</label>
                    <div class="col-md-9">
                        @Html.Partial("_BootstrapFileUploadImg",
                            new ViewDataDictionary() {
                                {"name","FaceImg" },
                                {"oriUrl",Url.Content(Model.FaceImgPath??"~/images/user_default_face.png") }
                            }
                        )
                    </div>

                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span>@Html.DisplayNameFor(m => m.UserName)
                    </label>
                    <div class="col-md-7">
                        <p class="form-control-static">
                            @if (isEdit)
                            {
                                @Model.UserName
                                @Html.HiddenFor(m => m.UserName)
                            }
                            else
                            {
                                @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
                                @Html.ValidationMessageFor(m => m.UserName)
                            }
                        </p>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span> @Html.DisplayNameFor(m => m.Password)
                    </label>
                    <div class="col-md-7">
                        <input type="password" id="Password" name="Password" class="form-control" />
                        @*@Html.ValidationMessageFor(m => m.Password)*@
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span>@Html.DisplayNameFor(m => m.TrueName)
                    </label>
                    <div class="col-md-7">
                        @Html.TextBoxFor(m => m.TrueName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.TrueName)
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span>@Html.DisplayNameFor(m => m.Email)
                    </label>
                    <div class="col-md-7">
                        @Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Email)
                    </div>
                </div>
                @*<div class="form-group">
                    <label class="col-md-3 control-label">
                        @Html.DisplayNameFor(m => m.StoreManger.QQEmailCode)
                    </label>
                    <div class="col-md-7">
                        
                        @Html.DisplayFor(m => m.StoreManger.QQEmailCode)
                        @*Model.StoreManger.QQEmailCode
                        @Html.HiddenFor(m => m.StoreManger.QQEmailCode, new { @class = "form-control" })
                    </div>
                </div>*@
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span> @Html.DisplayNameFor(m => m.Phone)
                    </label>
                    <div class="col-md-7">
                        @Html.TextBoxFor(m => m.Phone, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.Phone)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span> @Html.DisplayNameFor(m => m.StoreManger.StoreId)
                    </label>
                    <div class="col-md-7">
                        @Html.DropDownListFor(m => m.StoreManger.StoreId, Model.StoreManger.Stores,  new { @class = "form-control select2" })
                        @Html.ValidationMessageFor(m => m.StoreManger.StoreId)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-3 control-label">
                        <span style="color:red">*</span>@Html.DisplayNameFor(m => m.Roles)
                    </label>
                    <div class="col-md-7">
                        <select id="Role" name="Role" class="select2 form-control " multiple="multiple">
                            @{
                                Model.Roles = Model.Roles.ToList();
                                foreach (var role in (IEnumerable<Peninsula.DataAccess.POCO.Role>)ViewBag.AllRoles)
                                {
                                    string roleSelectStr = "";
                                    if (Model.Roles.Any(r => r.RoleName == role.RoleName))
                                    {
                                        roleSelectStr = "selected=\"selected\"";
                                    }
                                    <option value="@role.Id" @roleSelectStr>@role.RoleName</option>
                                }
                            }
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-3 col-md-7">
                        @Html.ValidationSummary()
                    </div>
                </div>
            </div>
            <div class="form-actions fluid">
                <div class="col-md-offset-3 col-md-9">
                    <button type="submit" class="btn btn-success">保存</button>
                    <a href="@HttpContext.Current.Request.UrlReferrer" class="btn btn-default">取消</a>
                </div>
            </div>
                                }

    </div>
</div>